package net.lzzy.practices.entities;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Entity
@Getter
@Setter
public class Chapter extends BaseEntity {
    private String name;

    private String description;

    private boolean open;
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;

    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
    //章节所属课程
    @ManyToOne
    private Course course;
    @OneToMany(mappedBy = "chapter")
    private List<Question> questions =new ArrayList<>();

    public Chapter() {
        createTime=new Date();
        updateTime=new Date();
    }

    public void setTeacher(User teacher) {
        course.setTeacher(teacher);
    }
}
